package QualificationRound.EnergyConversion;

import java.util.Scanner;

public class Bate1
{
	private static Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args)
	{
		int n=0,m=0,v=0,k=0;
		
		for(int j=sc.nextInt(); j>0; j--)
		{
			n=sc.nextInt();
			m=sc.nextInt();
			v=sc.nextInt();
			k=sc.nextInt();
			
			if(m>=n || m < (m-v)*k)
			{
				int i=0;
				while(m<n)
				{
					m=(m-v)*k;
					
					i++;
				}
				System.out.println(i);
			}
			else
			{
				System.out.println(-1);
			}
		}
	}

}
